package org.example.JavaBean;

import org.apache.commons.beanutils.PropertyUtils;

public class SimpleDemo {
    public static void main(String[] args) {
        try {
            MusicPlayer_Plus player = new MusicPlayer_Plus();

            System.out.println("=== 正常调用 ===");
            String result1 = player.getPlayMusic();  // 直接调用
            System.out.println("直接调用结果: " + result1);
            System.out.println();

            System.out.println("=== 使用PropertyUtils动态调用 ===");
            // 现在应该能正常工作了！
            Object result2 = PropertyUtils.getProperty(new MusicPlayer_Plus(), "playMusic");
            System.out.println(result2);
            System.out.println("PropertyUtils调用结果: " + result2);
            System.out.println();

            System.out.println("=== 调用普通getter ===");
            Object volume = PropertyUtils.getProperty(player, "volume");
            System.out.println("获取音量: " + volume);
            System.out.println();

            System.out.println("=== 使用setter方法 ===");
            PropertyUtils.setProperty(player, "volume", "80%");

        } catch (Exception e) {
            System.out.println("❌ 发生错误: " + e.getMessage());
            e.printStackTrace();
        }
    }
}